<?php
class Workflow_Service_UserTaskSmartyRender implements Workflow_Service_UserTaskRender
{
	protected $template;
	protected $parameters;
	
	public function __construct($rendercontent, array $parameters = array())
	{
		$this->parameters = $parameters;
		$this->template = $rendercontent;
	}
	
	public function render(Workflow_Execution $execution)
	{
		$parameters = array_merge($this->parameters, $execution->getVariables());
		
		if (!class_exists('Smarty', true)) {
            require_once 'Smarty/Smarty.class.php';
        }
        
        $smarty = new \Smarty();
        $smarty->caching = 0;
        
        $smarty->left_delimiter = "{";
        $smarty->right_delimiter = "}";
        $smarty->assign($parameters);
        
        return $smarty->fetch('string:'.$this->template);	
	}
}
?>